package com.gohome.gohomechat.ui.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gohome.gohomechat.GoHomeHelper;
import com.gohome.gohomechat.GoHomeModel;
import com.gohome.gohomechat.R;
import com.gohome.gohomechat.ui.activity.CircleActivity;
import com.gohome.gohomechat.ui.activity.MyQRCodeActivity;
import com.gohome.gohomechat.ui.activity.PersonalActivity;
import com.gohome.gohomechat.ui.activity.ScanActivity;
import com.gohome.gohomechat.utils.ToActivityUtil;

/**
 * Created by dllo on 16/3/1.
 */
public class OtherFragment extends BaseFragment implements View.OnClickListener {
    private LinearLayout mine_friendCircle;
    private LinearLayout mine_personal,mine_myqrcode,mine_scanqrcode;
    private TextView mine_username;
    private ImageView mine_head;
    @Override
    protected int getLayout() {
        return R.layout.fragment_other;
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    protected void initView(View view) {
        mine_personal= (LinearLayout) view.findViewById(R.id.mine_personal);
        mine_friendCircle = (LinearLayout) view.findViewById(R.id.mine_friendCircle);
        mine_username= (TextView) view.findViewById(R.id.mine_username);
        mine_head= (ImageView) view.findViewById(R.id.mine_head);
        mine_myqrcode= (LinearLayout) view.findViewById(R.id.mine_myqrcode);
        mine_scanqrcode= (LinearLayout) view.findViewById(R.id.mine_scanqrcode);
        mine_personal.setOnClickListener(this);
        mine_friendCircle.setOnClickListener(this);
        mine_myqrcode.setOnClickListener(this);
        mine_scanqrcode.setOnClickListener(this);
    }

    @Override
    protected void initData() {
        mine_username.setText(GoHomeModel.getInstance().getCurrentUserName());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.mine_personal:
                ToActivityUtil.startToActivity(getActivity(), PersonalActivity.class);
                break;
            case R.id.mine_friendCircle:
                ToActivityUtil.startToActivity(getActivity(),CircleActivity.class);
                break;
            case R.id.mine_myqrcode:
                ToActivityUtil.startToActivity(getActivity(), MyQRCodeActivity.class);
                break;
            case R.id.mine_scanqrcode:
                ToActivityUtil.startToActivity(getActivity(), ScanActivity.class);
                break;
        }
    }

    @Override
    public void onResume() {
        mine_username.setText(GoHomeModel.getInstance().getCurrentUserName());
        mine_head.setImageBitmap(GoHomeHelper.getInstance().getCurrentUserHead());
        super.onResume();
    }
}
